1. Field of the Invention
The invention relates to information processing and storage systems. More particularly, it relates to methods, apparatuses and articles of manufacture for manipulating information contained in a database system.
2. Description of the Related Art
An aggregate combines several entities into a single entity. In many database systems there is no support to define and implement user-defined aggregate functions.
For example, consider a table with a spatial column that contains several geometric shapes, one in each row. In database systems without native support for generating an aggregate there is no simple way to construct a single geometric value that represents the union of all the geometries in the column, or a subset thereof. FIGS. 1A and 1B illustrate an aggregate function. Each of the polygons 102 through 112 shown in FIG. 1A constitutes a single value in a database table in which each of the values is represented in a single row. A tabular representation for the polygons shown in FIG. 1A is shown below in Table 1, which shows rows having stored therein information for the polygon shape and other information related to that shape.
TABLE 1geometryother columnspolygon1. . . polygon2. . . polygon3. . . polygon4. . . polygon5. . . polygon6. . . 
An aggregation of the polygons shown in FIG. 1A can be described by equation 1 set forth below and is shown by shape 114 in FIG. 1B.polygon1 union polygon2 union polygon3 union polygon4 union polygon5 union polygon6  Eq. 1
In more abstract terms, entities can be combined into an aggregate entity according to the following equation, Eq. 2, set forth below, where v1 . . . vn are values of type t, and op is an operation.v1 op v2 op . . . op vn  Eq.2
A database system that implements recursive queries as defined in the SQL-99 standard (ISO/IEC 9075-2) provides the facilities to create aggregates. However, such solutions tend to be rather complex as recursion introduces its own set of complexities which are well-known and not described here. An example of the use of recursion to generate an aggregate is illustrated by the SQL-like statements shown in Table 2 below.
TABLE 2WITH union_tab(result, row_no) AS (SELECT geometry, 1FROM  tableWHERE <first row>UNION ALLSELECT union (result, geometry), row_no +1FROM  table, union_tabWHERE <next row, based on row_no>)SELECT geometryFROM  union_tabWHERE row_no =( SELECT MAX (row_no)FROM  union_tab )
It is well-known how to establish correlations between various rows in a database when using recursive techniques. However, there are several drawbacks to those approaches. First, when using recursion an iteration over the rows is required, so some sort of unique counter is needed. Also, infinite loops can occur when using recursion, which cannot be easily, if at all, detected by the database management system (DBMS). Further, the technique shown in Table 2 is not useable in practice.
Accordingly, there is a need for user-defined aggregate functions for use with database systems that do not use recursive programming techniques.